package com.example.demo.service;

import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class TestVinService<T> {

    public boolean isTestVin(String vin) {
        if (vin.endsWith("232")) {
            return false;
        }
        return true;
    }

    public T getServiceByVin(Map<String,T> serviceMap, String vin) {
        if (serviceMap == null) {
            return null;
        }
        if (isTestVin(vin)) {
            for (Map.Entry<String, T> entry : serviceMap.entrySet()) {
                if (entry.getKey().endsWith("TestVin")) {
                    return entry.getValue();
                }
            }
        } else {
            for (Map.Entry<String, T> entry : serviceMap.entrySet()) {
                if (!entry.getKey().endsWith("TestVin")) {
                    return entry.getValue();
                }
            }
        }
        return null;
    }

}
